<?php defined('SEJUJOPEFDNGJSL') or exit('Access denied');?>
<?php
if(empty($_SESSION["checkscode"])||!strstr($_SESSION["checkscode"],'buy_gocoin')){
    $_GET["m"]="buy_gocoin";
    @require(ROOTTHEMETEMP."checkscode.inc.php");
    exit;
}
if(!isset($_GET['templist'])){
?>
    <?php require("topbut.php") ?>
    <script type="text/javascript" src="<?php echo SITETHEME;?>js/main.js"></script>
    <div class="panel panel-inverse">
        <div class="panel-heading">
            <div class="row">
                <div class="col-md-12">
                    <h4 class="panel-title" style="float: left;">购买消费劵</h4>
                    <a href="<?php echo $GLOBALARR['curl']?>&templist=1" style="color: #fff;float: right;">查看购买记录</a>
                </div>
            </div>
        </div>
        <div class="panel-body">
            <form action="control.php" method="post" onsubmit="return chkbuycoin()">
                <input type="hidden" name="act" value="buy_gocoin">
                <fieldset style="border:none;">
                    <legend>注意：一个消费劵需要<?php echo $GLOBALARR['tran_num'];?>个商品积分。</legend>
                    <div class="form-group">
                        <label for="exampleInputEmail1">购买数量</label>
                        <input type="text" name="jine" id="jine" class="form-control" />
                    </div>
                    <button type="submit" class="btn btn-md btn-success m-r-5">确定</button>
                </fieldset>
            </form>
        </div>
    </div>

<?php
}else{
?>
<?php require("topbut.php") ?>
    <div class="panel panel-inverse">
        <div class="panel-heading">
            <div class="row">
                <div class="col-md-12">
                    <h4 class="panel-title" style="float: left;">我的转账记录</h4>
                    <a href="<?php echo $GLOBALARR['curl']?>" style="color:#fff;float: right;">返回</a>
                </div>
            </div>
        </div>
        <div class="panel-body">
            <div class="table-responsive">
                <table class="table table-striped givetable">
                  <tbody>
                    <tr >
                        <th>序号</th>
                        <th>购买者</th>
                        <th>购买数量</th>
                        <th>购买时间</th>
                        <th>备注</th>
                    </tr>
                <?php
                $pagecount=10;
                $condition=" where buyid= ".$_userid;
                $psql="select count(0) from ld_buy_coin_log $condition";
                $db->query($psql,3);
                $pcount=$db->fval;
                $pagecount=$pagecount;   //每页条数
                $astr="&lsact=buy_gocoin&templist=1";    //Url
                $pagearr=pagelist($pagecount,$pcount,$astr);
                $offset=$pagearr[1];

                $sql="select * from ld_buy_coin_log $condition order by id desc limit $offset,$pagecount";
                $db->query($sql);
                $rs=$db->rs;
                $ii=0;
                foreach ($rs as $k => $v) {
                  $ii++;
                  $serialid=($pagearr[2]-1)*$pagecount+$ii;
                ?>
                    <tr>
                        <td ><?php echo $serialid?></td>
                        <td><?php echo $v['buyname']?></td>
                        <td><?php echo formatrmb($v['num'])?>&nbsp;</td>
                        <td><?php echo formatdate($v['buytime'],0)?></td>
                        <td><?php echo $v['tbz']?></td>
                    </tr>
                <?php
                }
                ?>
                  </tbody>
                </table>
            </div>
        </div>
    </div>
<!-- <div class="right_center">我的转账记录 <a href="<?php echo $GLOBALARR['curl']?>" style="color: red;">返回</a></div> -->

<?php if(($pcount/$pagecount)>1){?>
<div class="pagediv"><?php echo $pagearr[0]?></div>
<?php }?>
<?php if($pcount==0){?>
<div class="pagediv" style="text-align:center;color:#E47501">--> 暂无数据</div>

<?php
}
}
?>